GameOverState =class("GameOverState",function() return StateBase.new() end)
local scheduler = import("framework.scheduler")
function GameOverState:onEnter()
   print("GameOverState onEnter")
   viewController:resetTime()
   local scene =display.getRunningScene()
   scheduler.unscheduleGlobal(scene.schedule)
   transition.stopTarget(scene.AnimationLayer)
   self:uiGameOver(scene.uiLayer)
   scene:vabration()
end


function GameOverState:uiGameOver(uiLayer)
   self:fishGameOver(uiLayer.fish)
   local frame1 =display.newSprite("gameover/blood.png",display.cx,display.cy)
   local frame2 =display.newSprite("gameover/white.png",display.cx,display.cy)
   uiLayer:addChild(frame1)
   uiLayer:addChild(frame2)
   frame2:setVisible(false)
    scheduler.performWithDelayGlobal(function () 
          uiLayer:removeChild(frame1)
          frame2:setVisible(true)
      end,1/20)
    scheduler.performWithDelayGlobal(function () 
        uiLayer:removeChild(frame2)
  end,3/20)
  
end

 function GameOverState:fishGameOver(fish)
   transition.stopTarget(fish.fish)
   fish:removeChild(fish.fish)
   fish.fishDead:setVisible(true)
   fish.fish  =fish.fishDead
   fish.fishDead:setRotation(80)
   transition.moveTo(fish.fishDead,{y=100,time=1,easing="easeInCirc",onComplete=function () 
      display.getRunningScene():vabration()
     transition.fadeOut(fish.fishDead,{time=0.5,onComplete = handler(fish,fish.deadEffect)})
     end}) 

end